package com.xjtu.platform.security.emailConfirm.dao;

import com.xjtu.platform.security.emailConfirm.EmailConfirmDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface EmailConfirmDao {
    @Update("update user set flag=#{code} where user_id=#{user_id}")
    void insertFlag(@Param("code") int code, @Param("user_id") String user_id);

    @Select("select email from user where user_id=#{user_id}")
    String getEmail(String user_id);

    @Select("select count(user_id) from user where email=#{email} and flag=#{userCode}")
    int confirmEmail(EmailConfirmDto emailConfirmDto);

    @Select("select count(email) from user where email=#{dto.email}")
    int isUnique(@Param("dto") EmailConfirmDto emailConfirmDto, @Param("user_id") String user_id);

    @Select("select flag from user where user_id=#{user_id}")
    String getFlag(String user_id);
}
